- 2 minutes to read

Configuration

You must provide the configuration in either code (explicit) or by using the configuration file appsettings.json (implicit)

  1. Code
  2. Appsettings.json

1. Code

string nodiniteApiUrl = "https://yourenv/nodinite/logapi/";

var settings = new NodiniteLogEventSettings()
{
    LogAgentValueId = 42,
    EndPointDirection = 0,
    EndPointTypeId = 0,
    EndPointUri = "Nodinite.Serilog.ApiSink.Tests.Serilog",
    EndPointName = "Nodinite.Serilog.ApiSink.Tests",
    ProcessingUser = "NODINITE",
    ProcessName = "Nodinite.Serilog.LogApiSink.Tests",
    ProcessingMachineName = "NODINITE-DEV",
    ProcessingModuleName = "DOTNETCORE.TESTS",
    ProcessingModuleType = "DOTNETCORE.TESTPROJECT"
};

ILogger log = new LoggerConfiguration()
   .WriteTo.NodiniteApiSink(nodiniteApiUrl, settings)
   .CreateLogger();

2. Appsettings.json

{
  "Serilog": {
    "Using": [ "Nodinite.Serilog.Apisink" ],
    "WriteTo": [
      {
        "Name": "NodiniteApiSink",
        "Args": {
          "NodiniteApiUrl": "",
          "Settings": {
            "LogAgentValueId": 42,
            "EndPointName": "Nodinite.Serilog.ApiSink.Tests",
            "EndPointUri": "Nodinite.Serilog.ApiSink.Tests.Serilog",
            "EndPointDirection": 0,
            "EndPointTypeId": 86,
            "OriginalMessageTypeName": "https://ACME.com/Customers/1.0#Batch",
            "ProcessingUser": "NODINITE",
            "ProcessName": "Nodinite.Serilog.ApiSink.Tests",
            "ProcessingMachineName": "NODINITE-DEV",
            "ProcessingModuleName": "DOTNETCORE.TESTS",
            "ProcessingModuleType": "DOTNETCORE.TESTPROJECT"
          }
        }
      }
    ]
  }
}
var configuration = new ConfigurationBuilder()
    // NOTE: If required, make sure to set the base path, for example: 
    // .SetBasePath(Directory.GetCurrrentDirectory())
    .AddJsonFile("appsettings.json")
    .Build();

Logger log = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();